package com.young.design.pattern.proxy.cglib;

/**
 * @ClassName : SimpleServiceTest
 * @Author : hyy
 * @Date: 2020-03-19
 */
public class SimpleServiceTest {
    public static void main(String[] args) {
       // 版本1： 不适用代理，直接调用 simpleService类中方法
       // doMethod(new SimpleService());
        // 版本2/版本3：非boss 用户不能调用方法，开发query 方法的调用
        SimpleServiceMethodInterceptor simpleServiceMethodInterceptor = new SimpleServiceMethodInterceptor("boss");
        SimpleServiceMethodInterceptor simpleServiceMethodInterceptor1 = new SimpleServiceMethodInterceptor("zhangsan");
        doMethod(simpleServiceMethodInterceptor.getProxy());
        doMethod(simpleServiceMethodInterceptor1.getProxy());


    }

    public static void doMethod(SimpleService simpleService){
        simpleService.insert();
        simpleService.update();
        simpleService.query();
        simpleService.delete();
    }
}
